Layout Attribute which Compares Multi-Valued Enumerations

Hi there,

I am fairly new at DXL and I want to make a layout column which compares 2 multi-valued lists and determine if they are the same for each object. If they are the same, I need the DXL column to say "True".

Attribute 1 Name = Variant
Attribute 2 Name = Category

They both pull from the same Attribute Type, so they have the same list choices.

Any help would be greatly appreciated.

Thank you.

Mike
Mike_the_SE - Thu Apr 28 09:15:26 EDT 2011

Re: Layout Attribute which Compares Multi-Valued Enumerations
llandale - Thu Apr 28 12:43:25 EDT 2011

Not going to test this, but perhaps this will work:

// Notice that variable "obj" is pre-defined Object, 
//    and for Layout and Attr-DXL it has the handle of "this object".
string val1 = probeAttr_(obj, "Variant")
string val2 = probeAttr_(obj, "Category")
if (val1 == val2) //
then display ("True")
else display ("")


Having said that, I'm guessing that at some point in time you will want to know which objects have identical values and which do not, such as filtering for those that do not. In that case, you are better off making an Attr-DXL which creates an attribute containing the value, and then display that attribute in a column. That attr-DXL would be for you type 'string' and would look like this:

 

// Notice that variable "obj" is pre-defined Object, 
//    and for Layout and Attr-DXL it has the handle of "this object".
string val1 = probeAttr_(obj, "Variant")
string val2 = probeAttr_(obj, "Category")
if (val1 == val2) //
then obj.attrDXLName = "True"
else obj.attrDXLName = " "


I would probably make it a boolean attribute set to true or false; but you want it to have values True or nothing.

 

 

 

  • Louie

 

 

Re: Layout Attribute which Compares Multi-Valued Enumerations
Mike_the_SE - Thu Apr 28 13:46:30 EDT 2011

llandale - Thu Apr 28 12:43:25 EDT 2011

Not going to test this, but perhaps this will work:

// Notice that variable "obj" is pre-defined Object, 
//    and for Layout and Attr-DXL it has the handle of "this object".
string val1 = probeAttr_(obj, "Variant")
string val2 = probeAttr_(obj, "Category")
if (val1 == val2) //
then display ("True")
else display ("")


Having said that, I'm guessing that at some point in time you will want to know which objects have identical values and which do not, such as filtering for those that do not. In that case, you are better off making an Attr-DXL which creates an attribute containing the value, and then display that attribute in a column. That attr-DXL would be for you type 'string' and would look like this:

 

// Notice that variable "obj" is pre-defined Object, 
//    and for Layout and Attr-DXL it has the handle of "this object".
string val1 = probeAttr_(obj, "Variant")
string val2 = probeAttr_(obj, "Category")
if (val1 == val2) //
then obj.attrDXLName = "True"
else obj.attrDXLName = " "


I would probably make it a boolean attribute set to true or false; but you want it to have values True or nothing.

 

 

 

  • Louie

 

 

Hi Louie! Thanks for the response!

Yes, your attribute DXL did work as I described, however I realize that I described it incorrectly. What I have is the two attributes (I changed the names from "Variant" to "Applicable Categories" and "Category" to "Category Tested" to make things a little clearer). Both can be multiple values from the same enumerated type. Some example data is as such:

Example Object 1
Applicable Categories = CAT I, CAT II, CAT III
Category Tested = CAT II, CAT III

Example Object 2
Applicable Categories = CAT I, CAT II
Category Tested = CAT III

(Commas indicate the separate values in the enum list)

And what I want is to identify with "True" any time the "Category Tested" attribute has any one of the "Applicable Categories" attribute's values. So, in my 2 examples above, Object 1 would return "True" and Object 2 would return "False" ("False" is ok rather than nothing).

If anyone knows how to do this I would definitely appreciate the help!

Mike

Re: Layout Attribute which Compares Multi-Valued Enumerations
llandale - Thu Apr 28 14:48:12 EDT 2011

Mike_the_SE - Thu Apr 28 13:46:30 EDT 2011
Hi Louie! Thanks for the response!

Yes, your attribute DXL did work as I described, however I realize that I described it incorrectly. What I have is the two attributes (I changed the names from "Variant" to "Applicable Categories" and "Category" to "Category Tested" to make things a little clearer). Both can be multiple values from the same enumerated type. Some example data is as such:

Example Object 1
Applicable Categories = CAT I, CAT II, CAT III
Category Tested = CAT II, CAT III

Example Object 2
Applicable Categories = CAT I, CAT II
Category Tested = CAT III

(Commas indicate the separate values in the enum list)

And what I want is to identify with "True" any time the "Category Tested" attribute has any one of the "Applicable Categories" attribute's values. So, in my 2 examples above, Object 1 would return "True" and Object 2 would return "False" ("False" is ok rather than nothing).

If anyone knows how to do this I would definitely appreciate the help!

Mike

That is a little trickier. Again I'm not going to bother to test this, but here's some code that should get you going. I'm going to restate your requirement in an equivalent manner such that it makes the DXL easier: you want True if there is any enumerated selected in both attributes.

AttrDef  ad = find(Name1)
AttrType at = ad.type
int       Size = at.size, i
bool     Match =false
string   NameEnum
 
for (i=0; i<Size; i++)
{  NameEnum = at.strings[i]
   if (isMember(obj.Name1, NameEnum)  and
      isMember(obj.Name2, NameEnum)) then Match = true
}

 

  • Louie

 

Re: Layout Attribute which Compares Multi-Valued Enumerations
Mike_the_SE - Fri Apr 29 08:21:52 EDT 2011

llandale - Thu Apr 28 14:48:12 EDT 2011

That is a little trickier. Again I'm not going to bother to test this, but here's some code that should get you going. I'm going to restate your requirement in an equivalent manner such that it makes the DXL easier: you want True if there is any enumerated selected in both attributes.

AttrDef  ad = find(Name1)
AttrType at = ad.type
int       Size = at.size, i
bool     Match =false
string   NameEnum
 
for (i=0; i<Size; i++)
{  NameEnum = at.strings[i]
   if (isMember(obj.Name1, NameEnum)  and
      isMember(obj.Name2, NameEnum)) then Match = true
}

 

  • Louie

 

Hi,

I tried your script as follows:
 

Module m = current
AttrDef  ad = find (m, "Applicable Categories")
AttrType at = ad.type
int      Size = at.size, i
bool     Match = false
string   NameEnum
 
for (i=0; i<Size; i++) {
   NameEnum = at.strings[i]
   if (isMember(obj."Applicable Categories", NameEnum)  and
      isMember(obj."Category Tested", NameEnum)) { 
      Match = true 
   }
}

 


However, it doesn't return any result at all, all combinations return a blank. What am I missing?

Mike

 

Re: Layout Attribute which Compares Multi-Valued Enumerations
llandale - Fri Apr 29 11:55:54 EDT 2011

Mike_the_SE - Fri Apr 29 08:21:52 EDT 2011

Hi,

I tried your script as follows:
 

Module m = current
AttrDef  ad = find (m, "Applicable Categories")
AttrType at = ad.type
int      Size = at.size, i
bool     Match = false
string   NameEnum
 
for (i=0; i<Size; i++) {
   NameEnum = at.strings[i]
   if (isMember(obj."Applicable Categories", NameEnum)  and
      isMember(obj."Category Tested", NameEnum)) { 
      Match = true 
   }
}

 


However, it doesn't return any result at all, all combinations return a blank. What am I missing?

Mike

 

Well, I figured you would take "Match" and do something with it, like insert it into the above script to determine whether to display "True" or not.
if (Match) //
then obj.attrDXLName = "True"
else obj.attrDXLName = " "

  • Louie

Re: Layout Attribute which Compares Multi-Valued Enumerations
Mike_the_SE - Fri Apr 29 13:48:23 EDT 2011

llandale - Fri Apr 29 11:55:54 EDT 2011
Well, I figured you would take "Match" and do something with it, like insert it into the above script to determine whether to display "True" or not.
if (Match) //
then obj.attrDXLName = "True"
else obj.attrDXLName = " "

  • Louie

Hi Louie,

Thank you very much! That was the piece I was missing. It works beautifully now. I really appreciate the help!

Mike

Re: Layout Attribute which Compares Multi-Valued Enumerations
SystemAdmin - Tue Mar 12 11:30:41 EDT 2013

Mike_the_SE - Fri Apr 29 13:48:23 EDT 2011
Hi Louie,

Thank you very much! That was the piece I was missing. It works beautifully now. I really appreciate the help!

Mike

I am having a similar issue as this thread. I have tried the things that were mentioned above. I have an enumerated type attribute that has following values "A1 , A2, A3, A4". what I am trying to do is have a lay out column that populates based off of what is in this column. Below is a sample of what I have tried to do.
 

AttrType at = find(current Module, "Test Attr")
int    Size = at.size, i
bool    Match = false
int     NameEnum
string  T1 = "A0"
 
for (i = 0; i < Size; i++) {
        NameEnum = at.values[i]
        if (0 == NameEnum) { // Or the String using at.strings[i] i have tryed both?
        Match = true
        }
        if (Match) {
        display "X"
        }
}

 


What I am trying to accomplish is the following output for the column(s):

Test Attr A0 Check DXL Layout
Object 1: A0, A1 X
Object 2: A0 X
Object 3: A1
Object 4: A2
Object 5: A0, A1 X

Any help is appreceated....

 

Re: Layout Attribute which Compares Multi-Valued Enumerations
llandale - Tue Mar 12 12:48:46 EDT 2013

SystemAdmin - Tue Mar 12 11:30:41 EDT 2013

I am having a similar issue as this thread. I have tried the things that were mentioned above. I have an enumerated type attribute that has following values "A1 , A2, A3, A4". what I am trying to do is have a lay out column that populates based off of what is in this column. Below is a sample of what I have tried to do.
 

AttrType at = find(current Module, "Test Attr")
int    Size = at.size, i
bool    Match = false
int     NameEnum
string  T1 = "A0"
 
for (i = 0; i < Size; i++) {
        NameEnum = at.values[i]
        if (0 == NameEnum) { // Or the String using at.strings[i] i have tryed both?
        Match = true
        }
        if (Match) {
        display "X"
        }
}

 


What I am trying to accomplish is the following output for the column(s):

Test Attr A0 Check DXL Layout
Object 1: A0, A1 X
Object 2: A0 X
Object 3: A1
Object 4: A2
Object 5: A0, A1 X

Any help is appreceated....

 

I don't see how this "layout" will not always display X or not display X.

"string[i]" displays the 'string' Enumeration; "values[i]" displays the associated 'int' value default 0.

You have a concept problem here. Your code queries the defin of the Type and does not query the value of the displayed object.

string    ValueDesired = "A0"
     // Use the "Definition" name of the attribute, not the "Type" name:
if (isMember(obj."Test Attr", ValueDesired)) //
then display "No"
else display "X"


-Louie